#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;

int main()
{
  ofstream outfile("map.html");
  outfile << "<style>\
  .core0 {width:10px;background-color:red}\
  .core1 {width:10px;background-color:green}\
  .core2 {width:10px;background-color:blue}\
  .core3 {width:10px;background-color:yellow}\
  .shared {width:10px;background-color:#ff00ff}\
  .unused {width:10px;background-color:gray}\
</style>" << endl;

  //the label
  outfile << "<table border='0' cellspacing='0' cellpadding='0'  style='border-collapse:collapse;'><tr>" << endl;
  for(int i=0;i<4;i++)
    //<td>core0</td><td width='5px'></td><td class='core0' style='border:1px solid black'></td><td width='20px'>
    outfile << "<td>core" << i << "</td><td width='5px'></td><td class='core" << i << "' style='border:1px solid black'></td><td width='20px'>" << endl;

  outfile << "<td>shared</td><td width='10px'></td><td class='shared' style='border:1px solid black'></td><td width='20px'>" << endl;
  outfile << "<td>unused</td><td width='10px'></td><td class='unused' style='border:1px solid black'></td><td width='20px'>" << endl;
  outfile << "<tr style='height:10px'></tr>" << endl;
  outfile << "</table>" << endl;


  for(int line=0;line<32;line++)
    {
  outfile << "<table border='1' cellspacing='0' cellpadding='0'  style='border-collapse:collapse;border:1px solid black';width:100%>" <<endl;
  outfile << "<tr>" << endl;
  
  for(int i=0;i<32;i++)                 //output each line
    {
      outfile << "<td>" << endl;
      outfile << "<table border='0' cellspacing='0' cellpadding='0' style='border-collapse:collapse;height:10px;'><tr>" << endl;
      for(int j=0;j<4;j++)          //output each word
        {
          int r = rand()%10;        //the data of memory
          if(r <= 3) {
              //outfile << "<td class='core0'></td>" << endl;
              outfile << "<td class='core" << r << "'></td>" << endl;
            } else if(r == 4)
            outfile << "<td class='shared'></td>" << endl;
          else
            outfile << "<td class='unused'></td>" << endl;
        }
      outfile << "</tr></table>" << endl;
      outfile << "</td>" << endl;
    }
  
  outfile << "</tr>" << endl;
  outfile << "</table>" << endl;
    } //for line
  
  outfile.close();
  cout << "generate map.html" << endl;
}









